package com.zhaorl.utils;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Description 将字符串渲染到客户端
 * @Author zhaorl
 * @Date 2023/3/28 15:01
 */
public class WebUtils {

    /**
     * @description
     * @param response 渲染对象
     * @param string 待渲染的字符串
     * @return String
     */
    public static String renderString(HttpServletResponse response,String string){

        response.setStatus(200);
        response.setCharacterEncoding("utf-8");
        response.setContentType("application/json");
        try {
            response.getWriter().print(string);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

}
